﻿(function () {
  'use strict';

  var app = angular.module('ng4model');

  // Collect the routes
  app.constant('routes', getRoutes());

  //app.config(['$stateProvider', '$urlRouterProvider', function ($stateProvider, $urlRouterProvider) {

  //  $urlRouterProvider.otherwise("/home");

  //  $stateProvider.state('home', {
  //    url: '',
  //    templateUrl: 'app/dashboard/dashboard.html'
  //  });
  //}]);

  // Configure the routes and route resolvers
  app.config(['$routeProvider', 'routes', routeConfigurator]);
  function routeConfigurator($routeProvider, routes) {

    routes.forEach(function (r) {
      $routeProvider.when(r.url, r.config);
    });
    $routeProvider.otherwise({ redirectTo: '/' });
  }

  // Define the routes 
  function getRoutes() {
    return [
        {
          url: '/',
          config: {
            templateUrl: '/EasyAuthorPortal/App/Dash',
            title: 'dashboard',
            settings: {
              nav: 1,
              content: '<i class="icon-dashboard"></i> Dashboard'
            }
          }
        }, {
          url: '/projects',
          config: {
            templateUrl: '/EasyAuthorPortal/Project/Index',
            title: 'projects',
            settings: {
              nav: 2,
              content: '<i class="icon-dashboard"></i> Projects'
            }
          }
        }, {
          url: '/project/:id',
          config: {
            // translate angular route into MVC route
            templateUrl: function (params) { return '/EasyAuthorPortal/Project/Project/'; },
            title: 'project',
            settings: {
              nav: false,
              content: '<i class="icon-dashboard"></i> Texts'
            }
          }
        }, {
          url: '/opus/:id',
          config: {
            templateUrl: function (params) { return '/EasyAuthorPortal/Project/Opus/'; },
            title: 'opus',
            settings: {
              nav: false,
              content: '<i class="icon-dashboard"></i> Text'
            }
          }
        }, {
          url: '/messagecenter',
          config: {
            templateUrl: '/EasyAuthorPortal/App/Messages',
            title: 'messagecenter',
            settings: {
              nav: 3,
              content: '<i class="icon-dashboard"></i> Message Center'
            }
          }
        }, {
          url: '/newproject',
          config: {
            templateUrl: '/EasyAuthorPortal/Project/NewProject',
            title: 'newproject',
            settings: {
              nav: false,
              content: '<i class="icon-dashboard"></i> New Project'
            }
          }
        }, {
          url: '/editproject/:id',
          config: {
            templateUrl: function (params) { return '/EasyAuthorPortal/Project/EditProject/'; },
            title: 'editproject',
            settings: {
              nav: false,
              content: '<i class="icon-dashboard"></i> Edit Project'
            }
          }
        }, {
          url: '/admin',
          config: {
            title: 'admin',
            templateUrl: '/EasyAuthorPortal/App/Settings',
            settings: {
              nav: 4,
              content: '<i class="icon-lock"></i> Settings'
            }
          }
        }
    ];
  }
})();